﻿package com.alstudio.module.sns.weiboshare;

import java.util.HashMap;
import java.util.Map;

public final class WeiboShareFactory {
	public static final int TENCENT_SHARE = 1;
	public static final int FACEBOOK_SHARE = 2;
	public static final int TWITTER_SHARE = 3;
	public static final int SINA_SHARE = 4;
	public static final int WEIXIN_SHARE = 5;

	private static Map<Integer, IWeiboShare> mInstanceMap = new HashMap<Integer, IWeiboShare>();

	public static IWeiboShare getInstance(int type) {
		IWeiboShare instance = mInstanceMap.get(new Integer(type));

		if (instance == null) {
			switch (type) {
			case TENCENT_SHARE:
				instance = createTencentShare();
				break;

			case FACEBOOK_SHARE:
//				instance = createFacebookShare();
				break;

			case TWITTER_SHARE:
//				instance = createTwitterShare();
				break;

			case SINA_SHARE:
				instance = createSinaShare();
				break;
			case WEIXIN_SHARE:
				instance = createWeiXinShare();
				break;

			default:
				instance = null;
				break;
			}
		}

		if (instance != null)
			mInstanceMap.put(new Integer(type), instance);

		return instance;
	}

	public static void reset() {
		mInstanceMap.clear();
	}

	private static IWeiboShare createTencentShare() {
		return new TencentShare();
	}

//	private static IWeiboShare createFacebookShare() {
//		return new FacebookShare();
//	}

//	private static IWeiboShare createTwitterShare() {
//		return new TwitterShare();
//	}

	private static IWeiboShare createSinaShare() {
		return new SinaShare();
	}
	
	private static IWeiboShare createWeiXinShare() {
		return new WeiXinShare();
	}
}
